import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import cptt from './modules/cptt'
import ht from './modules/ht'
Vue.use(Vuex)

import { getAdver } from '@/api/elseApis.js'
export default new Vuex.Store({
  modules: {
    user,cptt,ht
  },
  state:{
    advertising:[]
  },
  mutations:{
    SET_ADVER:(state,data)=>{ state.advertising = data }
  },
  actions: {
    GET_ADVER:async ({commit,}) => {
      let { adver } = await getAdver().catch(e=>{
        console.error(e)
        return {adver:[false]}
      })
      if(adver[0] && adver.length <4 )
        adver.push([true])
      console.log({adver})
      commit('SET_ADVER',adver)
    }
  },
  getters:{
	  advertising:state=>state.advertising,
  }
})